var mongoose=require('mongoose');
var Post=mongoose.model('Post',{
    title:String,
    authors:[String],
    comments:[
        {
            content:String,
            like:Number
        }
    ],
    test:Array
});
var db=mongoose.connect('mongodb://localhost/MongoDB_QuanWei_2');

var title='post11';
Post.update({title:title},{
    test:['a','b','c']
},{upsert:true},(err,r)=>{
    console.log('Update:',err,r);

    Post.update({title:title},{
        $pull:{test:'b'}
    },(e,r)=>{
        console.log('$pull "b":',e,r);

        Post.find({title:title},(e,r)=>{
            console.log('Find:\n',e,r);
            process.exit(1);
        });
    });

});


/*
 * $pull:{field:val}
 *
 * 删除数组字段中指定值
 * */





